/**
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
 */

#include "plugins/ecmascript/runtime/global_env.h"
#include "plugins/ecmascript/compiler/ecmascript_extensions/thread_environment_api.h"

namespace ark::ecmascript {
extern "C" uint64_t EcmaResolveSecondArgument(uint64_t functionTaggedValue)
{
    JSTaggedValue jsFunc(functionTaggedValue);
    if (jsFunc.IsJSFunction() && !JSFunction::Cast(jsFunc.GetHeapObject())->IsStrict()) {
        return JSThread::GetCurrentRaw()->GetEcmaVM()->GetGlobalEnv()->GetGlobalObject().GetRawData();
    }
    return JSTaggedValue::Undefined().GetRawData();
}
}  // namespace ark::ecmascript
